﻿
namespace NetROS.Tiers.Windows.Forms
{
	/// <summary>
	/// abstract SklDZahtjevGlava typed datagridview
	/// </summary>
	[System.ComponentModel.DesignerCategoryAttribute("code")]
	public abstract class SklDZahtjevGlavaDataGridViewBase : System.Windows.Forms.UserControl
	{	
		/// <summary> 
		/// Thrown when the current Entity changed.
		/// </summary>
		public event System.EventHandler<SklDZahtjevGlavaDataGridViewEventArgs> CurrentEntityChanged;
		
		#region Fields
				
		/// <summary> 
		/// the current entity.
		/// </summary>
		private Entities.SklDZahtjevGlava _currentSklDZahtjevGlava = null;
		//private Dictionary<string, string> _columnsHeaders = new Dictionary<string, string>();
		
		/// <summary> 
		/// the datagridview instance
		/// </summary>
		protected System.Windows.Forms.DataGridView uxSklDZahtjevGlavaDataGridView;
		
		/// <summary> 
		/// the errorprovider
		/// </summary>
		protected System.Windows.Forms.ErrorProvider uxSklDZahtjevGlavaErrorProvider;
		
		/// <summary> 
		/// the bindingsource
		/// </summary>
		protected System.Windows.Forms.BindingSource uxSklDZahtjevGlavaBindingSource;
		
		
		/// <summary> 
		/// the DGV column associated with the ID property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxIDDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Datum property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxDatumDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Oznaka property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxOznakaDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Server property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxServerDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the IDUser property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxIDUserDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the IDStatus property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxIDStatusDataGridViewColumn;
		
		#endregion
					
		#region Combo list
		
		#endregion
		
		#region Main Datasource
		
		private Entities.TList<Entities.SklDZahtjevGlava> _SklDZahtjevGlavaList;
				
		/// <summary> 
		/// The list of SklDZahtjevGlava to be displayed in the DGV.
		/// </summary>
		[System.ComponentModel.Category("Data")]
		public Entities.TList<Entities.SklDZahtjevGlava> SklDZahtjevGlavaList
		{
			get {return this._SklDZahtjevGlavaList;}
			set
			{
				this._SklDZahtjevGlavaList = value;
				this.uxSklDZahtjevGlavaBindingSource.DataSource = null;
				this.uxSklDZahtjevGlavaBindingSource.DataSource = value;
				this.uxSklDZahtjevGlavaDataGridView.DataSource = null;
				this.uxSklDZahtjevGlavaDataGridView.DataSource = this.uxSklDZahtjevGlavaBindingSource;				
				//this.uxSklDZahtjevGlavaBindingSource.ListChanged += new System.ComponentModel.ListChangedEventHandler(uxSklDZahtjevGlavaBindingSource_ListChanged);
				this.uxSklDZahtjevGlavaBindingSource.CurrentItemChanged += new System.EventHandler(OnSklDZahtjevGlavaBindingSourceCurrentItemChanged);
			}
		}
		
		private void OnSklDZahtjevGlavaBindingSourceCurrentItemChanged(object sender, System.EventArgs e)
		{
			_currentSklDZahtjevGlava = uxSklDZahtjevGlavaBindingSource.Current as Entities.SklDZahtjevGlava;
			
			if (_currentSklDZahtjevGlava != null)
			{
				_currentSklDZahtjevGlava.Validate();
			}
			//_SklDZahtjevGlava.Validate();
			OnCurrentEntityChanged();
		}

		//void uxSklDZahtjevGlavaBindingSource_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
		//{
			//throw new Exception("The method or operation is not implemented.");
		//}		
		
		#endregion
		
		/// <summary>
		/// Gets the currently selected <c cref="Entities.SklDZahtjevGlava"/> instance.
		/// </summary>
		public Entities.SklDZahtjevGlava SelectedSklDZahtjevGlava
		{
			get {return this._currentSklDZahtjevGlava;}
		}
		
		#region other properties
		
		/// <summary>
		/// Gets or sets a value indicating whether you have provided your own data-management operations for the DataGridView control.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool VirtualMode
		{
			get {return this.uxSklDZahtjevGlavaDataGridView.VirtualMode;}
			set
			{
				this.uxSklDZahtjevGlavaDataGridView.VirtualMode = value;
			}
		}
		
		/// <summary>
		/// Gets or sets a value indicating whether the option to add rows is displayed to the user.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool AllowUserToAddRows
		{
			get {return this.uxSklDZahtjevGlavaDataGridView.AllowUserToAddRows;}
			set {this.uxSklDZahtjevGlavaDataGridView.AllowUserToAddRows = value;}
		}
		
		/// <summary>
		/// Gets or sets a value indicating whether the user is allowed to delete rows from the DataGridView.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool AllowUserToDeleteRows
		{
			get {return this.uxSklDZahtjevGlavaDataGridView.AllowUserToDeleteRows;}
			set {this.uxSklDZahtjevGlavaDataGridView.AllowUserToDeleteRows = value;}
		}
		
		/// <summary>
		/// Gets the <c cref="DataGridView"/> instance.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public System.Windows.Forms.DataGridView DataGridView
		{
			get {return this.uxSklDZahtjevGlavaDataGridView;}
		}
		
		/// <summary>
		/// Gets a collection that contains all the columns in the control.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]		
		[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Visible)]
		//[System.ComponentModel.EditorAttribute("System.Windows.Forms.Design.DataGridViewColumnCollectionEditor, System.Design", typeof(System.Drawing.Design.UITypeEditor))] 
		public System.Windows.Forms.DataGridViewColumnCollection Columns
		{
			get { return this.uxSklDZahtjevGlavaDataGridView.Columns; }
		}
		
		#endregion
		
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;
	
		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}
	
		#region Constructor
	
		/// <summary>
		/// Initializes a new instance of the <see cref="SklDZahtjevGlavaDataGridViewBase"/> class.
		/// </summary>
		public SklDZahtjevGlavaDataGridViewBase()
		{			
			this.components = new System.ComponentModel.Container();			
			
			this.uxSklDZahtjevGlavaDataGridView = new System.Windows.Forms.DataGridView();
			this.uxSklDZahtjevGlavaBindingSource = new System.Windows.Forms.BindingSource(this.components);
			this.uxSklDZahtjevGlavaErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
			this.uxIDDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxDatumDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxOznakaDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxServerDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxIDUserDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxIDStatusDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			((System.ComponentModel.ISupportInitialize)(this.uxSklDZahtjevGlavaDataGridView)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxSklDZahtjevGlavaBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxSklDZahtjevGlavaErrorProvider)).BeginInit();
			this.SuspendLayout();
						
			// 
			// uxSklDZahtjevGlavaErrorProvider
			// 
			this.uxSklDZahtjevGlavaErrorProvider.ContainerControl = this;
			this.uxSklDZahtjevGlavaErrorProvider.DataSource = this.uxSklDZahtjevGlavaBindingSource;						
			// 
			// uxSklDZahtjevGlavaDataGridView
			// 
			this.uxSklDZahtjevGlavaDataGridView.AutoGenerateColumns = false;
			this.uxSklDZahtjevGlavaDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.uxSklDZahtjevGlavaDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
		this.uxIDDataGridViewColumn,
		this.uxDatumDataGridViewColumn,
		this.uxOznakaDataGridViewColumn,
		this.uxServerDataGridViewColumn,
		this.uxIDUserDataGridViewColumn,
		this.uxIDStatusDataGridViewColumn			});
			this.uxSklDZahtjevGlavaDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
			this.uxSklDZahtjevGlavaDataGridView.Location = new System.Drawing.Point(0, 0);
			this.uxSklDZahtjevGlavaDataGridView.Name = "uxSklDZahtjevGlavaDataGridView";
			this.uxSklDZahtjevGlavaDataGridView.Size = new System.Drawing.Size(470, 300);
			this.uxSklDZahtjevGlavaDataGridView.TabIndex = 0;	
			this.uxSklDZahtjevGlavaDataGridView.BackgroundColor = System.Drawing.Color.WhiteSmoke;
			this.uxSklDZahtjevGlavaDataGridView.EnableHeadersVisualStyles = false;
			this.uxSklDZahtjevGlavaDataGridView.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.OnSklDZahtjevGlavaDataGridViewDataError);
			this.uxSklDZahtjevGlavaDataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnSklDZahtjevGlavaDataGridViewCellValueNeeded);
			this.uxSklDZahtjevGlavaDataGridView.CellValuePushed += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnSklDZahtjevGlavaDataGridViewCellValuePushed);
			
			//
			// uxIDDataGridViewColumn
			//
			this.uxIDDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxIDDataGridViewColumn.DataPropertyName = "ID";
			this.uxIDDataGridViewColumn.HeaderText = "ID";
			this.uxIDDataGridViewColumn.Name = "uxIDDataGridViewColumn";
			this.uxIDDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxIDDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxIDDataGridViewColumn.ReadOnly = true;		
			//
			// uxDatumDataGridViewColumn
			//
			this.uxDatumDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxDatumDataGridViewColumn.DataPropertyName = "Datum";
			this.uxDatumDataGridViewColumn.HeaderText = "Datum";
			this.uxDatumDataGridViewColumn.Name = "uxDatumDataGridViewColumn";
			this.uxDatumDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxDatumDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxDatumDataGridViewColumn.ReadOnly = false;		
			//
			// uxOznakaDataGridViewColumn
			//
			this.uxOznakaDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxOznakaDataGridViewColumn.DataPropertyName = "Oznaka";
			this.uxOznakaDataGridViewColumn.HeaderText = "Oznaka";
			this.uxOznakaDataGridViewColumn.Name = "uxOznakaDataGridViewColumn";
			this.uxOznakaDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxOznakaDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxOznakaDataGridViewColumn.ReadOnly = false;		
			//
			// uxServerDataGridViewColumn
			//
			this.uxServerDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxServerDataGridViewColumn.DataPropertyName = "Server";
			this.uxServerDataGridViewColumn.HeaderText = "Server";
			this.uxServerDataGridViewColumn.Name = "uxServerDataGridViewColumn";
			this.uxServerDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxServerDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxServerDataGridViewColumn.ReadOnly = false;		
			//
			// uxIDUserDataGridViewColumn
			//
			this.uxIDUserDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxIDUserDataGridViewColumn.DataPropertyName = "IDUser";
			this.uxIDUserDataGridViewColumn.HeaderText = "IDUser";
			this.uxIDUserDataGridViewColumn.Name = "uxIDUserDataGridViewColumn";
			this.uxIDUserDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxIDUserDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxIDUserDataGridViewColumn.ReadOnly = false;		
			//
			// uxIDStatusDataGridViewColumn
			//
			this.uxIDStatusDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxIDStatusDataGridViewColumn.DataPropertyName = "IDStatus";
			this.uxIDStatusDataGridViewColumn.HeaderText = "IDStatus";
			this.uxIDStatusDataGridViewColumn.Name = "uxIDStatusDataGridViewColumn";
			this.uxIDStatusDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxIDStatusDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxIDStatusDataGridViewColumn.ReadOnly = false;		
			
			// this
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.Controls.Add(this.uxSklDZahtjevGlavaDataGridView);
			this.Name = "SklDZahtjevGlavaDataGridView";
			this.Size = new System.Drawing.Size(470, 300);
			((System.ComponentModel.ISupportInitialize)(this.uxSklDZahtjevGlavaErrorProvider)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxSklDZahtjevGlavaDataGridView)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxSklDZahtjevGlavaBindingSource)).EndInit();
			this.ResumeLayout(false);
		}
		#endregion
				
		#region events
		
		/// <summary>
		/// Raised the CurrentEntityChanged event.
		/// </summary>
		protected void OnCurrentEntityChanged()
		{
			if (CurrentEntityChanged != null)
			{
				SklDZahtjevGlavaDataGridViewEventArgs args = new SklDZahtjevGlavaDataGridViewEventArgs();
				args.SklDZahtjevGlava = _currentSklDZahtjevGlava;
				CurrentEntityChanged(this, args); 
			}
		}
		
		#endregion
		
		/// <summary>
		/// Strongly typed event 
		/// </summary>
		public class SklDZahtjevGlavaDataGridViewEventArgs : System.EventArgs
		{
			private Entities.SklDZahtjevGlava	_SklDZahtjevGlava;
	
			/// <summary>
			/// the  Entities.SklDZahtjevGlava instance.
			/// </summary>
			public Entities.SklDZahtjevGlava SklDZahtjevGlava
			{
				get { return _SklDZahtjevGlava; }
				set { _SklDZahtjevGlava = value; }
			}	
		}
		
		/// <summary>
		/// Handles the DataError event of the uxSklDZahtjevGlavaDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewDataErrorEventArgs"/> instance containing the event data.</param>
		protected void OnSklDZahtjevGlavaDataGridViewDataError(object sender, System.Windows.Forms.DataGridViewDataErrorEventArgs e)
		{
			System.Diagnostics.Debug.WriteLine(string.Format( "{0}, {1}", e.ColumnIndex, e.RowIndex));
		}
		
		/// <summary>
		/// Handles the CellValueNeeded event of the uxSklDZahtjevGlavaDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewCellValueEventArgs"/> instance containing the event data.</param>
		protected void OnSklDZahtjevGlavaDataGridViewCellValueNeeded(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e)
		{
			switch(uxSklDZahtjevGlavaDataGridView.Columns[e.ColumnIndex].Name)
			{
					case "uxIDDataGridViewColumn":
						e.Value = SklDZahtjevGlavaList[e.RowIndex].ID;
						break;
					case "uxDatumDataGridViewColumn":
						e.Value = SklDZahtjevGlavaList[e.RowIndex].Datum;
						break;
					case "uxOznakaDataGridViewColumn":
						e.Value = SklDZahtjevGlavaList[e.RowIndex].Oznaka;
						break;
					case "uxServerDataGridViewColumn":
						e.Value = SklDZahtjevGlavaList[e.RowIndex].Server;
						break;
					case "uxIDUserDataGridViewColumn":
						e.Value = SklDZahtjevGlavaList[e.RowIndex].IDUser;
						break;
					case "uxIDStatusDataGridViewColumn":
						e.Value = SklDZahtjevGlavaList[e.RowIndex].IDStatus;
						break;
				default:
				break;
			}
		}
		
		/// <summary>
		/// Handles the CellValuePushed event of the uxSklDZahtjevGlavaDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewCellValueEventArgs"/> instance containing the event data.</param>
		protected void OnSklDZahtjevGlavaDataGridViewCellValuePushed(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e)
		{
			switch(uxSklDZahtjevGlavaDataGridView.Columns[e.ColumnIndex].Name)
			{
					case "uxIDDataGridViewColumn":
						SklDZahtjevGlavaList[e.RowIndex].ID = (System.Int32)e.Value;
						break;
					case "uxDatumDataGridViewColumn":
						SklDZahtjevGlavaList[e.RowIndex].Datum = (System.DateTime)e.Value;
						break;
					case "uxOznakaDataGridViewColumn":
						SklDZahtjevGlavaList[e.RowIndex].Oznaka = (System.String)e.Value;
						break;
					case "uxServerDataGridViewColumn":
						SklDZahtjevGlavaList[e.RowIndex].Server = (System.String)e.Value;
						break;
					case "uxIDUserDataGridViewColumn":
						SklDZahtjevGlavaList[e.RowIndex].IDUser = (System.Int32)e.Value;
						break;
					case "uxIDStatusDataGridViewColumn":
						SklDZahtjevGlavaList[e.RowIndex].IDStatus = (System.Int32)e.Value;
						break;
				default:
				break;
			}
		}
	}
}
